<template>
	<view class="title">繁殖信息</view>
	<view class="mune">
		<view class="mune-titlie">
			<image src="@/static/cow/node.png" alt="" style="height: 20rpx;width: 20rpx;" />
			<view style="font-size: 24rpx;">出生</view>
		</view>
		<view class="mune-data">
			<view v-if="birthData">
				<view>出生时间: {{formatTime(birthData.brithday)}}</view>
				<view>公畜: IMEI: {{birthData.father}}</view>
				<view>母畜: IMEI: {{birthData.mother}}</view>
				<view>出生体重: {{birthData.Bweigth}}</view>
				<view>操作员: {{birthData.man}}</view>
			</view>
		</view>
		<!-- 发情模块 -->
		<view class="mune-titlie">
			<image src="@/static/cow/node.png" alt="" style="height: 20rpx;width: 20rpx;" />
			<view style="font-size: 24rpx;">发情</view>
		</view>
		<view class="mune-data">
			<view v-if="estrusData">
				<view>预测发情时间: {{formatTime(estrusData.F_EsTimateTime)}}</view>
				<view>实际发情时间: {{formatTime(estrusData.F_SjTimateTime)}}</view>
				<view>操作员: {{estrusData.F_Opert}}</view>
			</view>
		</view>
		<!-- 配种模块 -->
		<view class="mune-titlie">
			<image src="@/static/cow/node.png" alt="" style="height: 20rpx;width: 20rpx;" />
			<view style="font-size: 24rpx;">配种</view>
		</view>
		<view class="mune-data">
			<view v-if="breedingData">
				<view>配种时间: {{formatTime(breedingData.F_ReproTime)}}</view>
				<view>配种牲畜: IMEI: {{breedingData.F_IMEI}}</view>
				<view>操作员: {{breedingData.F_Man}}</view>
			</view>
		</view>
		<!-- 生育模块 -->
		<view class="mune-titlie">
			<image src="@/static/cow/node.png" alt="" style="height: 20rpx;width: 20rpx;" />
			<view style="font-size: 24rpx;">生育</view>
		</view>
		<view class="mune-data">
			<view v-if="birthGivingData">
				<view>生育时间: {{formatTime(birthGivingData.F_Birthday)}}</view>
				<view>生育牲畜: IMEI: {{birthGivingData.F_IMEI}}</view>
				<view>操作员: {{birthGivingData.F_Man}}</view>
			</view>
		</view>
		<!-- 节育模块 -->
		<view class="mune-titlie">
			<image src="@/static/cow/node.png" alt="" style="height: 20rpx;width: 20rpx;" />
			<view style="font-size: 24rpx;">节育</view>
		</view>
		<view class="mune-data">
			<view v-if="birthControlData">
				<view>节育时间: {{formatTime(birthControlData.F_SjTimateTime)}}</view>
				<view>操作员: {{birthControlData.F_Opert}}</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		onMounted
	} from 'vue';
	import {
		breedingInfo
	} from '@/utils/api/Livestock.js'
	import {
		onLoad
	} from '@dcloudio/uni-app'
	import dayjs from 'dayjs'
	const fId = ref('')

	// 出生数据
	const birthData = ref({});
	// 发情数据
	const estrusData = ref({});
	// 配种数据
	const breedingData = ref({});
	// 生育数据
	const birthGivingData = ref({});
	// 节育数据
	const birthControlData = ref({});



	onLoad((options) => {
		fId.value = options.fId
	})

	onMounted(async () => {
		const res = await breedingInfo({
			id: fId.value
		})
		
		if (res.code == 200) {
			birthData.value = res.data.brithDate
			estrusData.value = res.data.growthList
			breedingData.value = res.data.descentList
			birthGivingData.value = res.data.birth
			birthControlData.value = res.data.jyList
		}
	})
	
	//日期转换函数
	const formatTime = (time) => {
	    return dayjs(time).format('YYYY-MM-DD HH:mm:ss');
	}
</script>

<style scoped>
	.title {
		width: 100%;
		height: 80rpx;
		background-color: #EFEFEF;
		padding-left: 20rpx;
		line-height: 80rpx;
	}

	.mune-titlie {
		width: 80rpx;
		height: 50rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-left: 40rpx;
	}

	.mune-data {
		margin-left: 50rpx;
		margin-bottom: 20rpx;
		border-left: 1px solid #333;
	}

	.mune-data view {
		font-size: 20rpx;
		line-height: 30rpx;
		margin-left: 20rpx;
		padding: 10rpx 0;
	}
</style>